public class CalculateFitness {
	
	static int getFitness(Individual individual)
	{
		int fitness = 0;
		
		// Select all pairs
		for (int i = 0; i < individual.geneLength; i++) {
			for (int j = i + 1; j < individual.geneLength; j++) {
				
				//Check the Rules, if the two Queens can hit each other
				
				// Check Diagonal
				int distanceCol = Math.abs(i - j);
				int distanceRow = Math.abs(individual.gene[i] - individual.gene[j]);
				
				// Check Row and Diagonal
				if (individual.gene[i] != individual.gene[j] && distanceCol != distanceRow)
				{
					fitness++;
				}				
			}
		}

		return fitness;
	}
}
